<%var csstpl = {%>

    </style>
    <%};%>
        <%var jstpl = {%>
            <script>
                var app = new Vue({
                    el: "#content",
                    data: {
                        query: {
                            pageNumber: 1,
                            pageSize: 10,
                            name: ''
                        },
                        data_result: {},
                        level: '',
                        id: '',
                        state: '',
                        agentName: '',
                        price: '',
                        bank_user_name: '',
                        bank_name: '',
                        bank_num: '',
                    },
                    created: function() {
                        this.loadPage("init")
                    },
                    mounted() {
                        let form = layui.form;
                        let that = this;
                        form.on('submit(withdrawalSubmit)', function(data) {
                            console.log(data);
                            Ajax('/system/agent/withdrawal', data.field, function(d) {
                                if (d.state) {
                                    gx.alert(d.msg);
                                    that.loadPage();
                                    $("#withdrawalModal").modal('hide');
                                } else {
                                    gx.alert(d.msg);
                                }
                            })
                        })
                    },
                    methods: {
                        loadPage: function(model) { //载入模式有两种  init初始化载入 load分页载入
                            if (model == "init") {
                                this.query.pageNumber = 1;
                            }
                            Ajax("/system/agent/withdrawalHtml", this.query, function(d) {
                                app.data_result = d.list;
                                console.log(d);
                                if (d.firstPage == true) {
                                    layui.laypage.render({
                                        elem: 'gexin_page' //注意，这里的 test1 是 ID，不用加 # 号
                                            ,
                                        layout: ['count', 'prev', 'page', 'next',
                                            'limit', 'skip'
                                        ],
                                        count: d.totalRow //数据总数，从服务端得到
                                            ,
                                        limit: app.query.pageSize,
                                        jump: function(obj, first) {
                                            app.query.pageNumber = obj.curr;
                                            if (app.query.pageSize != obj.limit) {
                                                app.query.pageSize = obj.limit;
                                                app.loadPage("init");
                                                return;
                                            }
                                            if (!first) {
                                                app.loadPage("load");
                                            }
                                        }
                                    });
                                }
                            })
                        },
                        submit: function(agent) {
                            let that = this;
                            gx.confirm("确认同意代理商提现?", function() {
                                that.id = agent.id;
                                that.agentName = agent.agentName;
                                that.price = agent.price;
                                that.state = true;
                                that.bank_user_name = agent.bank_user_name;
                                that.bank_name = agent.bank_name;
                                that.bank_num = agent.bank_num;
                                that.$nextTick(function() {
                                        $("#withdrawalModal").modal('show');
                                    })
                                    // Ajax("/system/agent/withdrawal", {
                                    //     id: id,
                                    //     state: true
                                    // }, function(ret) {
                                    //     if (ret.state) {
                                    //         console.log(ret);
                                    //         that.loadPage("init");
                                    //         gx.alert(ret.msg);
                                    //     } else {
                                    //         gx.alert(ret.msg);
                                    //     }
                                    // })
                            })
                        },
                        submitNo: function(id) {
                            let that = this;
                            gx.confirm("确认拒绝代理商提现?", function() {
                                Ajax("/system/agent/withdrawal", {
                                    id: id,
                                    state: false
                                }, function(ret) {
                                    if (ret.state) {
                                        that.loadPage("init");
                                        gx.alert(ret.msg);
                                    } else {
                                        gx.alert(ret.msg);
                                    }
                                })
                            })
                        }
                    }
                })
            </script>
            <%};%>
                <%layout("../layout/_layout_layui.html",{title:"代理商提现管理",jstpl:jstpl,csstpl:csstpl}){%>
                    <div class="layui-row" id="content" v-cloak>

                        <!-- <div class="layui-col-md8">
                            <div class="layui-form-item">
                                <div class="layui-input-inline">
                                    <input type="text" name="admin.name" v-model="query.name" placeholder="输入城市名称模糊 查询" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                        </div>

                        <div class="layui-col-md3">
                            <div class="layui-form-item">
                                <a @click="loadPage" class="layui-btn"><i class="layui-icon">&#xe615;</i> 查询/筛选</a>
                                <a @click="add()" class="layui-btn ">添加</a>
                            </div>
                        </div> -->
                        <!-- 内容开始 -->
                        <div class="layui-col-md12" style="margin-top: 20px">
                            <table class="layui-table ">
                                <thead>
                                    <tr>
                                        <th>代理商名称</th>
                                        <th>提现金额</th>
                                        <th>申请时间</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody v-for="d in data_result">
                                    <td>{{d.agentName }}</td>
                                    <td>{{d.price }}</td>
                                    <td>{{d.create_time}}</td>
                                    <td>
                                        <a @click="submit(d)" class="layui-btn layui-btn-sm">同意提现</a>
                                        <a @click="submitNo(d.id)" class="layui-btn layui-btn-sm">拒绝提现</a>
                                    </td>
                                </tbody>
                                <tbody id="tbody_body" v-if="data_result.length==0">
                                    <tr>
                                        <td colspan="8" style="text-align:center;height:300px">
                                            <h1>没有数据</h1>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                            <fieldset id="gexin_page" class="layui-elem-field layui-field-title"></fieldset>
                        </div>


                        <div class="modal fade" id="withdrawalModal" tabindex="-1" role="dialog" aria-hidden="true">
                            <form id="auditForm" class="layui-form form-horizontal ">
                                <div class="modal-dialog">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <h4 class="modal-title">
                                                代理商充值
                                            </h4>
                                        </div>
                                        <div class="modal-body">
                                            <!-- 弹出框开始  -->
                                            <div class="layui-row layui-col-space15">
                                                <!-- 弹出框开始  -->
                                                <input type="hidden" id="" v-model="id" name="id">
                                                <input type="hidden" id="" v-model="state" name="state">
                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">代理商名称</label>
                                                    <div class="layui-input-block">
                                                        <input class="layui-input" type="text" lay-verify="required" v-model='agentName' readonly/>
                                                    </div>
                                                </div>
                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">提现金额</label>
                                                    <div class="layui-input-block">
                                                        <input class="layui-input" type="text" lay-verify="required" v-model='price' readonly/>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="modal-footer">
                                            <div class="layui-form-item">
                                                <div class="layui-input-block">
                                                    <button type="button" class="layui-btn" lay-submit lay-filter="withdrawalSubmit">提交</button>
                                                    <button type="button" data-dismiss="modal" class="layui-btn layui-btn-primary">关闭</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>

                    </div>
                    <%}%>